#pragma once
#include <cstdint>
#include <functional>
#include <iostream>
#include "InetAddr.hpp"

class Reactor;
using handler_t = std::function<std::string(std::string&)>;
class Connection {
public:
    Connection() : _events(0), _owner(nullptr) {
    }
    void SetEvent(const uint32_t events) {
        _events = events;
    }
    uint32_t GetEvent() {
        return _events;
    }
    void SetOwner(Reactor* owner) {
        _owner = owner;
    }
    Reactor* GetOwner() {
        return _owner;
    }
    virtual void Recver() = 0;
    virtual void Sender() = 0;
    virtual void Excepter() = 0;
    virtual int GetSockFd() = 0;
    void RegisterHandler(handler_t cb) {
        _handler = cb;
    }
    ~Connection() {}
private:
    uint32_t _events; // 关心的事件
    Reactor* _owner;
public:
    handler_t _handler;
};